package org.toonWatch
import com.metasieve.shoppingcart.Shoppable
import com.metasieve.shoppingcart.ShoppingItem

class Item extends com.metasieve.shoppingcart.Shoppable{
    
    //    int id
//    static searchable = true 
    String name
    Integer quantity
    Category category
    String description
    ShoppingItem shoppingItem
    String brand
    double price
    byte[] image
    
    static constraints = {
        //       id(matches: '[0-9]{8}') //primary key
        name(maxSize:30, blank:false, nullable:false, unique:true)
        quantity(maxSize:4, blank:false, nullable:false)
        description(maxSize:500, blank:false, nullable:false)
        brand(maxSize:50, blank:true, nullable:false)
    }
    
    static hasMany = [comments : Comment]
    
    static hasOne = [category : Category]
    
    static mapping = {
        image column: "image", sqlType: "longblob"
    }
    
    String toString() {
        name
    }
}
